<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/yq/admin/components/meta.html" />
    <title>有趣管理后台 ${metaTitleSuffix!}</title>
    <#include "/yq/admin/components/stylesheets.html" />
    <!-- <link href="https://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.min.css" rel="stylesheet"> -->
    <link href="//res.zhen-yee.com/assert/amazeui.2.7.2.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/yq/admin/assets/login.css?v=2">
</head>

<body>
    <div id="app">
        <!-- <div class="logo">
            <img src="/yq/admin/assets/img/logo.png" class="am-img-responsive" />
        </div> -->
        <div class="login-form" style="margin: 0 auto; width: 50%; min-width: 700px;">
            <div class="login-form-field">
                <div class="login-form-field-icon">
                    <img src="/yq/admin/assets/img/icon-user.png" class="am-img-responsive" />
                </div>
                <div class="login-form-field-input">
                    <input type="text" v-model="account" placeholder="账号" />
                </div>
            </div>
            <div class="login-form-field">
                <div class="login-form-field-icon">
                    <img src="/yq/admin/assets/img/icon-pwd.png" class="am-img-responsive" />
                </div>
                <div class="login-form-field-input">
                    <input type="password" v-model="password" placeholder="密码" @keyup.enter="login" />
                </div>
            </div>
        <div class="login-form-submit">
            <button class="am-btn theme-background-color1" @click="login">登录</button>
        </div>
    </div>
    <!-- <footer style="width: 50%; min-width: 700px; height: 60px; padding: 20px 3rem; margin: 0 auto;">
        <p>由 <a href="http://www.zhen-yee.com/" title="蓁奕科技" target="_blank" style="color: rgb(14, 144, 210);">蓁奕科技</a> 提供技术支持 CopyRight©2018 Zhenyi Tech Inc.</p>
    </footer> -->
    </div>
    <#include "/yq/admin/components/scripts.html" />
    <!-- <script src="https://cdn.bootcss.com/amazeui/2.7.2/js/amazeui.min.js"></script> -->
    <script src="//res.zhen-yee.com/assert/amazeui.2.7.2.min.js"></script>
    <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9/crypto-js.min.js"></script> -->
    <script src="//res.zhen-yee.com/assert/crypto-js.3.1.9.min.js"></script>
    <script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data() {
            return {
                account: '',
                password: ''
            }
        },
        mounted: function() {},
        methods: {
            login() {
                var self = this;
                if (!self.account) {
                    msg("请输入账号");
                    return;
                }
                if (!self.password) {
                    msg("请输入密码");
                    return;
                }
                var encoded = self.aesCBC(self.password);
                var param = Qs.stringify({
                    account: self.account,
                    password: encoded
                });
                loading();
                axios({
                        url: '/yq/admin/auth/login',
                        method: 'post',
                        data: param,
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded'
                        }
                    })
                    .then(function(response) {
                        endLoading();
                        if (response.data.status == 200) {
                            var loginUrl = response.data.info
                            var url = "${URL!''}"
                            if (url != '') {
                                window.location.href = url;
                                return;
                            } else {
                                window.location.href = loginUrl;
                                return;
                            }
                            // msg("登录成功");
                        } else {
                            msg("登录失败：" + response.data.msg);
                            console.log(response.data);
                        }
                    })
                    .catch(function(error) {
                        endLoading();
                        msg("登录失败：" + response.data.msg);
                        console.log(error);
                    });
            },
            aesCBC(text) {
                var aesText = text;
                var key = CryptoJS.enc.Utf8.parse('${key!}');
                var iv = CryptoJS.enc.Utf8.parse('RandomInitVector');
                aesText = CryptoJS.AES.encrypt(text, key, {
                    iv: iv,
                    mode: CryptoJS.mode.CBC,
                    padding: CryptoJS.pad.Pkcs7
                }).toString();
                return aesText;
            }
        }
    })
    </script>
    <script>
    // wx.ready(function() {
    //     initWXShare()
    // })
    </script>
</body>

</html>